Skip to content

Let a runner send earlier prompts' context by its label alone - #68

Merged
jeff377 merged 1 commit into
mainfrom
claude/earlier-context-by-label
Dec 1, 2026
Merged

jeff377 merged 1 commit into
mainfrom
claude/earlier-context-by-label

Conversation

@jeff377

@jeff377 jeff377 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Closes #67.

What

ChatRunner.SupersedesEarlierContext (Func<PromptContext, bool>?, default null):

  • When set, the latest prompt that carries a PromptContext the function accepts, and every prompt after it, send their context in full.
  • Each context of an earlier prompt is sent as <context label="…"> with a short note ("Sent with this earlier prompt and not repeated; a later prompt carries the current text.") in place of its text, so the model still knows what the prompt was about.
  • When no prompt carries an accepted context, every context is sent in full.
  • Only the request changes: the history, SaveHistory, LoadHistory and the views keep every context's text. The function is read for each request, including the one sent after the user approves a tool call.
  • Nothing changes when it is not set.

Polhem MD's need ("keep the latest prompt that carries the document or a selection, and every prompt after it") is context => isDocument(context.Label); "the latest prompt that has any context" is _ => true. Once this ships, polhem-dev/polhem-md can drop its EarlierContextChatClient wrapper.

Tests

EarlierContextTests: earlier context goes by label and the chosen prompt keeps it in full; context after the chosen prompt stays in full; nothing accepted sends everything in full; option not set behaves as before; a shortened prompt keeps its files; SaveHistory round-trips every copy.

Local: dotnet build (Release, 0 warnings), dotnet test (all three test projects), the Blazor script tests and check-md-links.sh all pass.

Downstream

New public API only (PublicAPI.Unshipped.txt updated); the Polhem framework sees no change unless it sets the property.

ChatRunner.SupersedesEarlierContext takes a function over a prompt's context. When it is set, the latest prompt that
carries a context the function accepts, and every prompt after it, send their context in full; each context of an
earlier prompt goes to the model as its label with a note that it is not repeated. The history, SaveHistory and the
views keep every context's text, and nothing changes when it is not set.
@jeff377
jeff377 enabled auto-merge (squash) December 1, 2026 14:11
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@jeff377
jeff377 merged commit 199e30e into main Dec 1, 2026
4 checks passed
@jeff377
jeff377 deleted the claude/earlier-context-by-label branch December 1, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let a conversation send earlier prompts' context by its label alone

1 participant